/**   
* @Title: DynamicRoutingDataSource.java
* @Package org.xaoyaoyao.cloud.dynamic.source
* @Description: TODO
* @author xaoyaoyao
* @date Jul 3, 2019 3:31:00 PM
* @version V1.0   
*/
package org.xaoyaoyao.cloud.dynamic.source;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: DynamicRoutingDataSource
 * @Description: TODO
 * @author xaoyaoyao
 * @date Jul 3, 2019 3:31:00 PM
 * 
 */
@Slf4j
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {

	@Override
	protected Object determineCurrentLookupKey() {
		String dataSourceName = DynamicDataSourceContextHolder.getDataSourceRouterKey();
		if (log.isInfoEnabled()) {
			log.info(">>>>>>>> 当前数据源是：{}", dataSourceName);
		}
		return DynamicDataSourceContextHolder.getDataSourceRouterKey();
	}

}
